import javax.swing.JOptionPane;


public class UpgradeTechnologyLevel extends UpgradeOrder{

  private Player Owner;
  private int[] TechnologyLevelCost = {20, 50, 80, 120, 150};
  private String[] TechnologyName = {"Infantry", "Automatic Weapons", "Rocket Launchers", "Tanks", "Improved TAnks", "Fighter Planes"};
  
  public UpgradeTechnologyLevel(Player _Owner){
	  Owner = _Owner;
  }
  
  public boolean checkOrder(){
	  if (Owner.getTechnologyLevel() > 4) {
		  JOptionPane.showMessageDialog(null, "You are at the highest technology level!");
	      return false;
	  }
	  if (Owner.getTechnology() < TechnologyLevelCost[Owner.getTechnologyLevel()]){
		  JOptionPane.showMessageDialog(null, "No enough technology to upgrade!");
		  return false;
	  }
	  return true;
  }
  
  public void excecuteOrder(){
	  Owner.upgradeTechnologyLevel();
	  Owner.cutTechnology(TechnologyLevelCost[Owner.getTechnologyLevel()]);
  }
  
  public  String printOrder(){
  	StringBuffer sentence = new StringBuffer();
  	sentence.append("Upgrade technology level to ");
  	sentence.append(TechnologyName[Owner.getTechnologyLevel() + 1]);
      return sentence.toString();
  }
}


